package com.example.administrator.yuejian35.Recommend.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.yuejian35.BaseListAdapter;
import com.example.administrator.yuejian35.R;
import com.example.administrator.yuejian35.Recommend.activity.CourseinfoActivity;
import com.example.administrator.yuejian35.Recommend.bean.Searchresult;
import com.example.administrator.yuejian35.Recommend.fragment.viewholder.ResultItemViewHolder;

import java.util.List;

/**
 * Created by HP on 2017/10/8.
 */

public class SearchresultAdapter extends BaseListAdapter {
    public SearchresultAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_result,parent,false);
        ResultItemViewHolder viewHolder = new ResultItemViewHolder(itemView);
        return viewHolder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, int position, List data) {
        ResultItemViewHolder viewHolder = (ResultItemViewHolder) holder;
        final Searchresult coursename = (Searchresult) data.get(position);
        viewHolder.course_name.setText(coursename.getCoursename());
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(!coursename.getCoursename().equals("暂无数据")){
                    Intent intent = new Intent(context,CourseinfoActivity.class);
                    intent.putExtra("courseid",coursename.getCourseid());
                    context.startActivity(intent);
                }
                else {

                }

            }
        });
    }
}
